package com.zonski.jbots.desktop.client.entity;

import java.awt.Graphics;
import java.awt.Color;

import com.zonski.jbots.engine.Rectangle;
import com.zonski.jbots.engine.Entity;
import com.zonski.jbots.engine.entity.MovingEntity;

import com.zonski.jbots.desktop.client.EntityRenderer;

import com.zonski.jbots.game.entity.ExplosionMind;

public class ExplosionRenderer implements EntityRenderer
{
    public ExplosionRenderer()
    {
    }

    public void render(Graphics g, Entity entity)
    {
        ExplosionMind mind = (ExplosionMind)((MovingEntity)entity).getMind();
        int thickness = mind.getMaxUpdates() - entity.getEffectiveModeUpdates();
        Rectangle bounds = entity.bounds;
        if(thickness > bounds.width/2)
        {
            thickness = bounds.width/2;
        }
        for(int i=0; i<thickness; i++)
        {
            int c = (i * 255)/(thickness);
            g.setColor(new Color(255, c, 0));
            g.drawOval(bounds.x+i, bounds.y+i, 
                    bounds.width-2*i-1, 
                    bounds.height-2*i-1);
        }
        g.setColor(Color.BLACK);
        g.drawOval(bounds.x, bounds.y, bounds.width, bounds.height);
    }
}
